package main

import (
	"fmt"
	"sync"
	"time"
)

var once sync.Once

func main() {
	for i, v := range make([]string, 10) {
		once.Do(Once)
		fmt.Println("count:", v, " ----- ", i)
	}
	for i := 0; i < 5; i++ {
		go func() {
			once.Do(Onced)
			fmt.Println("21312312")
		}()
	}
	time.Sleep(4000)
}

func Once() {
	fmt.Println("执行一次")
}

func Onced() {
	fmt.Println("执行onced")
}
